package com.ruoyi.quality.controller;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.quality.domain.TInspectionForm;
import com.ruoyi.quality.service.ITInspectionFormService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 整改巡检单记录Controller
 * 
 * @author mahl2
 * @date 2024-07-02
 */
@RestController
@RequestMapping("/quality/form")
public class TInspectionFormController extends BaseController
{
    @Autowired
    private ITInspectionFormService tInspectionFormService;

    /**
     * 查询整改巡检单记录列表
     */
    @PreAuthorize("@ss.hasPermi('quality:form:list')")
    @GetMapping("/list")
    public TableDataInfo list(TInspectionForm tInspectionForm)
    {
        startPage();
        List<TInspectionForm> list = tInspectionFormService.selectTInspectionFormList(tInspectionForm);
        return getDataTable(list);
    }

    /**
     * 导出整改巡检单记录列表
     */
    @PreAuthorize("@ss.hasPermi('quality:form:export')")
    @Log(title = "整改巡检单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TInspectionForm tInspectionForm)
    {
        List<TInspectionForm> list = tInspectionFormService.selectTInspectionFormList(tInspectionForm);
        ExcelUtil<TInspectionForm> util = new ExcelUtil<TInspectionForm>(TInspectionForm.class);
        util.exportExcel(response, list, "整改巡检单记录数据");
    }

    /**
     * 获取整改巡检单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('quality:form:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tInspectionFormService.selectTInspectionFormById(id));
    }

    /**
     * 新增整改巡检单记录
     */
    @PreAuthorize("@ss.hasPermi('quality:form:add')")
    @Log(title = "整改巡检单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public void add(@RequestBody TInspectionForm tInspectionForm , HttpServletResponse response, HttpServletRequest request)
    {
         tInspectionFormService.insertTInspectionForm(tInspectionForm,response,request);
    }

    /**
     * 行级倒出巡检单
     */
    @PreAuthorize("@ss.hasPermi('quality:form:export')")
    @Log(title = "整改巡检单记录", businessType = BusinessType.INSERT)
    @PostMapping("/exportInfo")
    public void exportInfo(@RequestBody TInspectionForm tInspectionForm , HttpServletResponse response, HttpServletRequest request)
    {
        tInspectionFormService.exportInfo(tInspectionForm,response,request);
    }

    /**
     * 修改整改巡检单记录
     */
    @PreAuthorize("@ss.hasPermi('quality:form:edit')")
    @Log(title = "整改巡检单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TInspectionForm tInspectionForm)
    {
        return toAjax(tInspectionFormService.updateTInspectionForm(tInspectionForm));
    }

    /**
     * 删除整改巡检单记录
     */
    @PreAuthorize("@ss.hasPermi('quality:form:remove')")
    @Log(title = "整改巡检单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tInspectionFormService.deleteTInspectionFormByIds(ids));
    }
}
